export = function (sourceId: string, roomName?: string): ICreepConfig {
  return {
    source: (creep: Creep) => {
      let spawn: Structure = Game.getObjectById<Structure>(sourceId);
      if (creep.withdraw(spawn, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) creep.moveTo(spawn)
    },
    // 建造
    target: (creep: Creep) => {
      if (roomName) {
        const room = Game.rooms[roomName];
        if (!room || creep.room.name != room.name) creep.moveTo(new RoomPosition(25, 25, roomName));
        else if (creep.room.name == room.name) {
          let construction: ConstructionSite = Object
            .values(Game.constructionSites)
            .filter(construct => construct.room.name == room.name)[0];
          creep.moveTo(construction);
          if (creep.build(construction) == ERR_NOT_IN_RANGE) creep.moveTo(construction)
          return
        }
      } else {
        if (global.creepNumber.carrier2 === 0
          || global.creepNumber.harvester1 === 0
          || global.creepNumber.harvester2 === 0
        ) {
          return;
        }
        let construction: ConstructionSite = Object.values(Game.constructionSites)[0];
        creep.moveTo(construction);
        if (creep.build(construction) == ERR_NOT_IN_RANGE) creep.moveTo(construction)
      }
    },
    // 状态切换条件，稍后会给出具体实现
    switch: (creep: Creep) => creep.updateState()
  }
}